import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @description: Hicvel连接类
 * @author: fengfazheng
 * @create: 2021-12-26 00:52
 **/
public class HiveConnectionUtils {
    // set the impalad host
    private static final String IMPALAD_HOST = "192.168.73.129";

    // port 21050 is the default impalad JDBC port
    private static final String IMPALAD_JDBC_PORT = "10000";

    private static final String CONNECTION_URL = "jdbc:hive2://" + IMPALAD_HOST + ':' + IMPALAD_JDBC_PORT + "/test";

    private static final String JDBC_DRIVER_NAME = "org.apache.hive.jdbc.HiveDriver";

    public static Connection getConnection(String url, String username, String password) throws ClassNotFoundException, SQLException {
        Class.forName(JDBC_DRIVER_NAME);
        return DriverManager.getConnection(CONNECTION_URL, username, password);
    }
}
